<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>跨域解决方案</title>
</head>
<body>
  <h3>jsonp</h3>
  <p>后台返回的数据是<span id="jsonp"></span></p>
  <script>
    var script = document.createElement('script')
    script.src = 'http://localhost:4000/api/jsonp?callback=handleClick'
    document.body.appendChild(script)
    function handleClick(data) {
      var jsonp = document.getElementById('jsonp')
      jsonp.innerText = data
    }
  </script>
</body>
</html>